<template>
  <div class="app-container">

    <h2>首页内容</h2>

    <!--修改密码窗口-->
    <el-dialog title="您的密码不符合规范，请修改密码" :visible.sync="resetPwdPanelShow"
               modal-append-to-body :close-on-click-modal="false" :close-on-press-escape="false"
               :show-close="false" center>
      <resetPwd ref="resetPwd" :showButtons="false"/>
      <div slot="footer">
        <el-button type="primary" size="medium" style="width: 40%" @click="confirmResetPwd">确认修改</el-button>
        <el-button type="danger" size="medium" style="width: 40%" @click.native="logout">退出登录</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import resetPwd from "@/views/system/user/profile/resetPwd";

export default {
  name: 'Index',
  data() {
    return {
      //修改密码
      resetPwdPanelShow: localStorage.getItem('weekPwd') === '1',
    }
  },
  components: {
    resetPwd
  },
  methods: {
    confirmResetPwd() {
      this.$refs.resetPwd.saveInfo(res => {
        if (res.code === 200) {
          setTimeout(() => {
            this.logout();
          })
        }
      })
    },
    logout() {
      this.$store.dispatch('LogOut').then(() => {
        location.reload()
      })
    }
  }
}
</script>
